home *** CD-ROM | disk | FTP | other *** search
/ Menu Planner / Menu Planner (Ohio Distinctive Software).ISO / pc / mp.dir / 00142_setButtonsFromArray.ls < prev    next >
Encoding:
Text File  |  1995-11-07  |  8.2 KB  |  296 lines

  1. on setButtonsFromArray
  2.   set whichSection to the frameLabel
  3.   if whichSection = "PDC" then
  4.     setPdcFromArray()
  5.   else
  6.     if whichSection = "breakfast" then
  7.       setBreakfastFromArray()
  8.     else
  9.       if whichSection = "breakfast veg" then
  10.         setBreakfastVegFromArray()
  11.       else
  12.         if whichSection = "brunch" then
  13.           setBrunchFromArray()
  14.         else
  15.           if whichSection = "brunch veg" then
  16.             setBrunchVegFromArray()
  17.           else
  18.             if whichSection = "lunch" then
  19.               setLunchFromArray()
  20.             else
  21.               if whichSection = "lunch veg" then
  22.                 setLunchVegFromArray()
  23.               else
  24.                 if whichSection = "dinner" then
  25.                   setDinnerFromArray()
  26.                 else
  27.                   if whichSection = "dinner veg" then
  28.                     setDinnerVegFromArray()
  29.                   else
  30.                     if whichSection = "dinner2" then
  31.                       setDinner2FromArray()
  32.                     else
  33.                       if whichSection = "dinner2 veg" then
  34.                         setDinner2VegFromArray()
  35.                       end if
  36.                     end if
  37.                   end if
  38.                 end if
  39.               end if
  40.             end if
  41.           end if
  42.         end if
  43.       end if
  44.     end if
  45.   end if
  46. end
  47.  
  48. on setPdcFromArray
  49.   setPDCNoFatFromArray()
  50.   setFatPercentFromArray()
  51.   setPDCFieldsFromArray()
  52. end
  53.  
  54. on setPDCFieldsFromArray
  55.   global calcdata
  56.   put string(getaProp(calcdata, #desired_calories)) into field "Calories"
  57.   if getaProp(calcdata, #twoMeals) then
  58.     put 2 into field "meals"
  59.   else
  60.     put 3 into field "meals"
  61.   end if
  62. end
  63.  
  64. on setPDCNoFatFromArray
  65.   global calcdata
  66.   set btnNames to "diabetes,heart,preg,hypr,vegt,under_19,low_fat,none"
  67.   set setOneGreen to 0
  68.   repeat with x = 1 to 8
  69.     set theValue to getAt(calcdata, x)
  70.     puppetSprite(x + 7, 1)
  71.     if theValue then
  72.       set the castNum of sprite (x + 7) to the number of cast ("green_" & item x of btnNames)
  73.       set setOneGreen to 1
  74.     else
  75.       set the castNum of sprite (x + 7) to the number of cast ("red_" & item x of btnNames)
  76.     end if
  77.     if x = 7 then
  78.       puppetSprite(45, 1)
  79.       set the visible of sprite 45 to theValue
  80.       puppetSprite(46, 1)
  81.       set the visible of sprite 46 to theValue
  82.       puppetSprite(47, 1)
  83.       set the visible of sprite 47 to theValue
  84.       puppetSprite(48, 1)
  85.       set the visible of sprite 48 to theValue
  86.       setFatPercentFromArray()
  87.     end if
  88.   end repeat
  89.   if not setOneGreen then
  90.     setaProp(calcdata, #none, 1)
  91.     set the castNum of sprite 15 to the number of cast "green_none"
  92.   end if
  93. end
  94.  
  95. on setFatPercentFromArray
  96.   global calcdata
  97.   if the visible of sprite 16 then
  98.     set theValue to getaProp(calcdata, #fat_percent)
  99.     repeat with x = 1 to 3
  100.       puppetSprite(x + 45, 1)
  101.       if theValue = x then
  102.         set the castNum of sprite (x + 45) to the number of cast ("green_fat_" & x)
  103.         next repeat
  104.       end if
  105.       set the castNum of sprite (x + 45) to the number of cast ("red_fat_" & x)
  106.     end repeat
  107.   end if
  108. end
  109.  
  110. on setLunchVegFromArray
  111.   setLunchFromArray()
  112. end
  113.  
  114. on setLunchFromArray
  115.   setLunchGroup1FromArray()
  116.   setLunchGroup2FromArray()
  117.   setLunchGroup3FromArray()
  118.   setLunchGroup4FromArray()
  119. end
  120.  
  121. on setLunchGroup1FromArray
  122.   global calcdata
  123.   set btnNames to "lun_meat,lun_pasta,lun_sand"
  124.   repeat with x = 1 to 3
  125.     set isOn to getAt(calcdata, x + 18)
  126.     puppetSprite(x + 13, 1)
  127.     if isOn then
  128.       set the castNum of sprite (x + 13) to the number of cast ("green_" & item x of btnNames)
  129.       next repeat
  130.     end if
  131.     set the castNum of sprite (x + 13) to the number of cast ("red_" & item x of btnNames)
  132.   end repeat
  133. end
  134.  
  135. on setLunchGroup2FromArray
  136.   global calcdata
  137.   set isSoup to getaProp(calcdata, #lun_soup)
  138.   puppetSprite(17, 1)
  139.   puppetSprite(18, 1)
  140.   if isSoup then
  141.     set the castNum of sprite 17 to the number of cast "green_lun_soup"
  142.     set the castNum of sprite 18 to the number of cast "red_lun_salad"
  143.   else
  144.     set the castNum of sprite 17 to the number of cast "red_lun_soup"
  145.     set the castNum of sprite 18 to the number of cast "green_lun_salad"
  146.   end if
  147. end
  148.  
  149. on setLunchGroup3FromArray
  150.   global calcdata
  151.   set isFruit to getaProp(calcdata, #lun_fruit)
  152.   puppetSprite(19, 1)
  153.   puppetSprite(20, 1)
  154.   if isFruit then
  155.     set the castNum of sprite 19 to the number of cast "green_lun_fruit"
  156.     set the castNum of sprite 20 to the number of cast "red_lun_juice"
  157.   else
  158.     set the castNum of sprite 19 to the number of cast "red_lun_fruit"
  159.     set the castNum of sprite 20 to the number of cast "green_lun_juice"
  160.   end if
  161. end
  162.  
  163. on setLunchGroup4FromArray
  164.   global calcdata
  165.   set isMilk to getaProp(calcdata, #lun_milk)
  166.   puppetSprite(21, 1)
  167.   puppetSprite(22, 1)
  168.   if isMilk then
  169.     set the castNum of sprite 21 to the number of cast "green_lun_milk"
  170.     set the castNum of sprite 22 to the number of cast "red_lun_cheese"
  171.   else
  172.     set the castNum of sprite 21 to the number of cast "red_lun_milk"
  173.     set the castNum of sprite 22 to the number of cast "green_lun_cheese"
  174.   end if
  175. end
  176.  
  177. on setBrunchFromArray
  178.   setBreakfastFromArray()
  179. end
  180.  
  181. on setBrunchVegFromArray
  182.   setBreakfastVegFromArray()
  183. end
  184.  
  185. on setBreakfastFromArray
  186.   setBreakfastGroup1FromArray()
  187.   setBreakfastGroup2FromArray()
  188. end
  189.  
  190. on setBreakfastVegFromArray
  191.   setBreakfastFromArray()
  192. end
  193.  
  194. on setBreakfastGroup1FromArray
  195.   global calcdata
  196.   set btnNames to "brk_eggs,brk_meat,brk_pancakes,brk_cereal,brk_potatoes"
  197.   repeat with x = 1 to 5
  198.     set theValue to getAt(calcdata, x + 11)
  199.     puppetSprite(x + 17, 1)
  200.     if theValue then
  201.       set the castNum of sprite (x + 17) to the number of cast ("green_" & item x of btnNames)
  202.       next repeat
  203.     end if
  204.     set the castNum of sprite (x + 17) to the number of cast ("red_" & item x of btnNames)
  205.   end repeat
  206. end
  207.  
  208. on setBreakfastGroup2FromArray
  209.   global calcdata
  210.   set isFruit to getaProp(calcdata, #brk_fruit)
  211.   puppetSprite(23, 1)
  212.   puppetSprite(24, 1)
  213.   if isFruit then
  214.     set the castNum of sprite 23 to the number of cast "green_brk_fruit"
  215.     set the castNum of sprite 24 to the number of cast "red_brk_juice"
  216.   else
  217.     set the castNum of sprite 23 to the number of cast "red_brk_fruit"
  218.     set the castNum of sprite 24 to the number of cast "green_brk_juice"
  219.   end if
  220. end
  221.  
  222. on setDinner2FromArray
  223.   setLunchGroup1FromArray()
  224.   setDinnerGroup2FromArray()
  225.   setDinnerGroup3FromArray()
  226.   setLunchGroup4FromArray()
  227.   setDinnerGroup4FromArray()
  228. end
  229.  
  230. on setDinner2VegFromArray
  231.   setDinner2FromArray()
  232. end
  233.  
  234. on setDinnerFromArray
  235.   setDinnerGroup1FromArray()
  236.   setDinnerGroup2FromArray()
  237.   setDinnerGroup3FromArray()
  238.   setDinnerGroup4FromArray()
  239. end
  240.  
  241. on setDinnerVegFromArray
  242.   setDinnerFromArray()
  243. end
  244.  
  245. on setDinnerGroup1FromArray
  246.   global calcdata
  247.   set isMeat to getaProp(calcdata, #din_meat)
  248.   puppetSprite(12, 1)
  249.   puppetSprite(13, 1)
  250.   if isMeat then
  251.     set the castNum of sprite 12 to the number of cast "green_din_meat"
  252.     set the castNum of sprite 13 to the number of cast "red_din_pasta"
  253.   else
  254.     set the castNum of sprite 12 to the number of cast "red_din_meat"
  255.     set the castNum of sprite 13 to the number of cast "green_din_pasta"
  256.   end if
  257. end
  258.  
  259. on setDinnerGroup2FromArray
  260.   global calcdata
  261.   set isBread to getaProp(calcdata, #din_bread)
  262.   puppetSprite(17, 1)
  263.   puppetSprite(18, 1)
  264.   if isBread then
  265.     set the castNum of sprite 17 to the number of cast "green_din_bread"
  266.     set the castNum of sprite 18 to the number of cast "red_din_potatoes"
  267.   else
  268.     set the castNum of sprite 17 to the number of cast "red_din_bread"
  269.     set the castNum of sprite 18 to the number of cast "green_din_potatoes"
  270.   end if
  271. end
  272.  
  273. on setDinnerGroup3FromArray
  274.   global calcdata
  275.   set isBread to getaProp(calcdata, #din_soup)
  276.   puppetSprite(19, 1)
  277.   puppetSprite(20, 1)
  278.   if isBread then
  279.     set the castNum of sprite 19 to the number of cast "green_din_soup"
  280.     set the castNum of sprite 20 to the number of cast "red_din_salad"
  281.   else
  282.     set the castNum of sprite 19 to the number of cast "red_din_soup"
  283.     set the castNum of sprite 20 to the number of cast "green_din_salad"
  284.   end if
  285. end
  286.  
  287. on setDinnerGroup4FromArray
  288.   global calcdata
  289.   puppetSprite(23, 1)
  290.   if getaProp(calcdata, #din_dessert) then
  291.     set the castNum of sprite 23 to the number of cast "green_din_dessert"
  292.   else
  293.     set the castNum of sprite 23 to the number of cast "red_din_dessert"
  294.   end if
  295. end
  296.